﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AirTickets
{
    public partial class BookingsForm : Form
    {
        public BookingsForm()
        {
            InitializeComponent();
        }

        List<Billete> billetes;

        private void Bookings_Load(object sender, EventArgs e)
        {
            ListaDeVuelos vuelos = new ListaDeVuelos();

            billetes = (from v in vuelos
                       from b in v.Billetes
                       select b).ToList<Billete>();

            lbBilletes.DataSource = billetes;
            lbBilletes.DisplayMember = "Descriptor";

        }

        private void lbBilletes_DoubleClick(object sender, EventArgs e)
        {
            ListBox l = (ListBox) sender;
            MouseEventArgs m = (MouseEventArgs)e;
            int i = l.IndexFromPoint(m.Location);
            Billete b = (Billete) ((List<Billete>)l.DataSource)[i];
            BilleteForm f = new BilleteForm(b);
            f.ShowDialog();
        }
    }
}
